package businessLayer.businessObjects;

import java.util.ArrayList;

import dataAccessLayer.abstractFactory.Factory;
import dataAccessLayer.abstractFactory.daos.DAOrecipes;
import dataAccessLayer.visualObject.VOrecipe;

public class RecipesBusinessObject 
{
	private DAOrecipes daoRecipes;
	
	public RecipesBusinessObject(Factory factory)
	{
		daoRecipes = factory.getDAOrecipes();
	}

	public Object[][] getRecipes() 
	{
		ArrayList<VOrecipe> recipes = daoRecipes.listRecipes();
		
		Object[][] resul = new Object[recipes.size()][1];
		
		for (int i = 0; i < resul.length; i++) 
		{
			resul[i][0] = recipes.get(i).getName();
		}
		
		return resul;
	}

	public Object[] searchRecipeDetail(String name) 
	{
		VOrecipe vOrecipe = new VOrecipe();
		
		vOrecipe.setName(name);
		
		vOrecipe = daoRecipes.searchRecipeByName(vOrecipe);
		
		Object[] resul = new Object[2];
		resul[0] = vOrecipe.getImage();
		resul[1] = vOrecipe.getDescription();
		
		return resul;
	}
}
